package com.ruoyi.web.controller.jypc;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jypc.domain.Tb1Specdirect;
import com.ruoyi.jypc.service.ITb1SpecdirectService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 专业方向Controller
 * 
 * @author xymc
 * @date 2022-11-14
 */
@RestController
@RequestMapping("/jypc/specdirect")
public class Tb1SpecdirectController extends BaseController
{
    @Autowired
    private ITb1SpecdirectService tb1SpecdirectService;

    /**
     * 查询专业方向列表
     */
    @PreAuthorize("@ss.hasPermi('jypc:specdirect:list')")
    @GetMapping("/list")
    public TableDataInfo list(Tb1Specdirect tb1Specdirect)
    {
        startPage();
        List<Tb1Specdirect> list = tb1SpecdirectService.selectTb1SpecdirectList(tb1Specdirect);
        return getDataTable(list);
    }

    /**
     * 导出专业方向列表
     */
    @PreAuthorize("@ss.hasPermi('jypc:specdirect:export')")
    @Log(title = "专业方向", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Tb1Specdirect tb1Specdirect)
    {
        List<Tb1Specdirect> list = tb1SpecdirectService.selectTb1SpecdirectList(tb1Specdirect);
        ExcelUtil<Tb1Specdirect> util = new ExcelUtil<Tb1Specdirect>(Tb1Specdirect.class);
        util.exportExcel(response, list, "专业方向数据");
    }

    /**
     * 获取专业方向详细信息
     */
    @PreAuthorize("@ss.hasPermi('jypc:specdirect:query')")
    @GetMapping(value = "/{sdId}")
    public AjaxResult getInfo(@PathVariable("sdId") Long sdId)
    {
        return AjaxResult.success(tb1SpecdirectService.selectTb1SpecdirectBySdId(sdId));
    }

    /**
     * 新增专业方向
     */
    @PreAuthorize("@ss.hasPermi('jypc:specdirect:add')")
    @Log(title = "专业方向", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Tb1Specdirect tb1Specdirect)
    {
        return toAjax(tb1SpecdirectService.insertTb1Specdirect(tb1Specdirect));
    }

    /**
     * 修改专业方向
     */
    @PreAuthorize("@ss.hasPermi('jypc:specdirect:edit')")
    @Log(title = "专业方向", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Tb1Specdirect tb1Specdirect)
    {
        return toAjax(tb1SpecdirectService.updateTb1Specdirect(tb1Specdirect));
    }

    /**
     * 删除专业方向
     */
    @PreAuthorize("@ss.hasPermi('jypc:specdirect:remove')")
    @Log(title = "专业方向", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sdIds}")
    public AjaxResult remove(@PathVariable Long[] sdIds)
    {
        return toAjax(tb1SpecdirectService.deleteTb1SpecdirectBySdIds(sdIds));
    }
}
